package com.library.service;

import com.library.bean.Admin;
import com.library.bean.ReaderCard;
import com.library.dao.AdminDao;
import com.library.dao.ReaderCardDao;
import com.library.entity.OaDepartment;
import com.library.mapper.OaDepartmentMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginService {

    private final static Logger log = LoggerFactory.getLogger(LoginService.class);

    @Autowired
    private ReaderCardDao readerCardDao;
    @Autowired
    private AdminDao adminDao;

    public ReaderCard hasMatchReader(String userName,String password){
        return  readerCardDao.getIdMatchByUserName(userName, password);
    }

    public ReaderCard findReaderCardByReaderId(long readerId){
        return readerCardDao.findReaderByReaderId(readerId);
    }

    public boolean adminRePassword(long adminId, String newPassword){
        int i = adminDao.resetPassword(adminId, newPassword);
        return true;
    }
    public String getAdminPassword(long adminId){
        return adminDao.getPassword(adminId);
    }

    public boolean readerRePassword(long readerId, String newPassword) {
        return readerCardDao.resetPassword(readerId, newPassword) > 0;
    }

    public String getReaderPassword(long readerId) {
        return readerCardDao.getPassword(readerId);
    }


}
